<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
	String path = request.getContextPath() + "/";
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<head>
<base href="<%=basePath%>">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
<title>朗读亭——朗读录播管理</title>
<!-- Tell the browser to be responsive to screen width -->
<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, read-scalable=no"
	name="viewport">
</head>
<body>
	<section class="content-header">
      <h1>
        系统管理
        <small>朗读录播管理</small>
      </h1>
    </section>

    <!-- Main content -->
    <section class="content">
      <div id="myTabContent" class="tab-content">
		<!-- 查询面板 -->
		<div class="tab-pane active" id="search">
			<section class="content-header">
			<div class="row">
				<form id="typeForm">
				<input name="pageNo" id="pageNo" type="hidden"/>
				<input name="pageSize" id="pageSize" type="hidden" value="10"/>
				<div class="col-sm-2">
				<input type="text" class="form-control input-lg" id="cardno"
						name="cardno" placeholder="读者证号"></div>
				<div class="col-sm-2">
				<select name="isopen" class="form-control input-lg">
					<option value="">全部</option>
					<option value="1">公开</option>
					<option value="0">未公开</option>
				</select></div>
				<div class="col-sm-2">
				<input type="text" class="form-control input-lg" id="hasp"
						name="hasp" placeholder="电话号码"></div>
				</form>
				<div class="col-sm-2">
					<button class="btn btn-primary input-lg"
						onclick="searchList(1);">查询朗读录播</button>
				</div>
			</div>
			</section>
		</div>
	</div>
      <div class="row" style="margin-top:10px;">
        <div class="col-xs-12">

          <div class="box">
            <!-- /.box-header -->
            <div class="box-body">
              <table id="example1" class="table table-bordered table-striped">
                <thead>
                <tr>
                  <th>序号</th>
                  <th>卡号</th>
                  <th>姓名</th>
                  <th>所属机构</th>
                  <th>所用设备</th>
                  <th>观看次数</th>
                  <th>是否公开</th>
                  <th>是否删除</th>
                  <th>联系电话</th>
                  <th>朗读时间</th>
                  <th>操作</th>
                </tr>
                </thead>
						<tbody id="list">
						</tbody>
					</table>
				<div class="paging" id="pageInfo"></div>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    <!--播放 视频-->
    <div id="vH" style="display:none;">
	<div id="myModal" class="reveal-modal">
	</div>
	</div>
	
	<!-- 播放mp4 -->
	<video id="view" poster="img/p.jpg" autoplay controls style="display:none;position:fixed;width:50%;left:25%;top:50px;z-index:99"></video>
	
<script src="js/jquery-1.9.1.js"></script>
<script src="js/bootstrap.js"></script>
<script src="dist/js/app.min.js"></script>
<script src="js/page1.js"></script>
<script src="js/jwplayer.js"></script>
<script type="text/javascript" src="js/layer/layer.js"></script>
<script>
var thePlayer;
function playVedio(url){
	$('#myModal').html('');
	var media1 = '<div id="vd"></div>';
	$('#myModal').html(media1);
	$('#myModal').css("visibility","visible");
	thePlayer = jwplayer('vd').setup({  
        'flashplayer': 'jwplayer.flash.swf',  
        'file': url,  
        'width': '600',  
        'height': '450'
      });
	layer.open({
		title: '观看视频',
		type: 1,
		area: ['700px', '550px'],
		fixed: false, //不固定
		maxmin: true,
		content: $("#vH")
	});
}
function closeModal(){
	searchList($("#pageNo").val());
	//$('#myModal').html("");
	//$('#myModal').css("visibility","hidden");
}
$(document).ready(function() {
	searchList(1);
});
function searchList(pageNo){
	$("#pageNo").val(pageNo);
		$.ajax({
			async : false,
			cache : false,
			type : 'post',
			dataType : "json",
			data : $("#typeForm").serialize(),
			url : 'read/read_list_data' ,// 请求的action路径
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				layer.msg("请求失败！");
			},
			success : function(data) {
				if(data.state=="9003"){
					layer.msg("没有权限！");
					return ;
				}else if(data.state=="9002"){
					layer.msg("请重新登录！");
					top.location.reload();
					return ;
				}
					var list = data.list;
					var strHtml = "";
					var a = "";
					for(var i=0;i<list.length;i++){
						if(list[i].phoneno==null || list[i].phoneno==''){
							a = '<a class="btn btn-danger" href="javascript:void(0);"onclick="deleteItem('+list[i].id+')">删除</a>';
						}else{
							a = '<a class="btn btn-primary" target="_blank"  href="'+list[i].url+'">观看&下载</a>&nbsp;'+
						/* 	'<a class="btn btn-primary"  href="javascript:playMp4('+("'"+'http://139.224.17.20:8092'+list[i].url+"'")+');">预览</a>&nbsp;'+ */
							'<a class="btn btn-danger" href="javascript:void(0);"onclick="deleteItem('+list[i].id+')">删除</a>';
						}
						strHtml +='<tr><td>'+(pageNo*10+i-9)+'</td>'+
							'<td>'+list[i].cardno+'</td>'+
							'<td>'+list[i].uname+'</td>'+
							'<td>'+list[i].gname+'</td>'+
							'<td>'+list[i].dname+'</td>'+
							'<td>'+list[i].watchtimes+'</td>'+
							'<td>'+(list[i].isopen=='1'?'公开':'未公开')+'</td>'+
							'<td>'+(list[i].isdelete=='1'?'删除':'未删除')+'</td>'+
							'<td>'+list[i].phoneno+'</td>'+
							'<td>'+list[i].readdate+'</td>'+
							'<td>'+a+'</td></tr>';
					}
					if(list.length==0){
						strHtml = "<tr style=\"text-align:center;\"><td colspan=\"10\">找不到朗读录播信息！</td></tr>";
					}
					$("#list").html(strHtml);
					$("#pageInfo").html(pageInfo(data.totalPage,data.pageNumber));
					$("#totalRows").html(data.totalRow);
			}
		});	
}

	function playMp4(mp4){
		$('#view').attr('src',+mp4).show();			
	}
	$('#example1').click(function(){
		$('#view').hide();
	});

  function deleteItem(id){
	  layer.confirm('你确定要删除吗?', {
 		  title:'删除',
 		  btn: ['确定','取消'] //按钮
 		}, function(){  
  			$.ajax({
				async : false,
				cache : false,
				type : 'post',
				dataType : "json",
				url : 'read/delete_read?id='+id ,// 请求的action路径
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					layer.msg("请求失败！");
				},
				success : function(data) {
					if(data.state=="9003"){
						layer.msg("没有权限！");
						return ;
					}else if(data.state=="9002"){
						layer.msg("请重新登录！");
						top.location.reload();
						return ;
					}
					if(data){
						layer.msg("删除成功！");
						window.location.reload();
					}else
					{
						layer.msg("删除失败！");
					}
				}
			});	
 		}, function(){
  		});
  }
</script>
</body>
</html>